package com.ourteam.product.model.api;

import org.apache.commons.lang3.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.model.dao.IProductModelServiceParameterDAO;
import com.ourteam.product.model.dao.ProductModelServiceParameterDAOQueryBean;
import com.ourteam.product.model.domain.ProductModelServiceParameterBean;

public class ProductModelServiceParameterSearchBean
		extends AbstractSearchModel<ProductModelServiceParameterDAOQueryBean> {

	private long serviceId;

	private String parameterName;

	private String parameterType;

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductModelServiceParameterBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductModelServiceParameterDAOQueryBean queryBean) throws Exception {

		ProductModelServiceParameterDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (serviceId != 0) {
			criteria.andServiceIdEqualTo(serviceId);
		}

		if (StringUtils.isNotBlank(parameterName)) {
			criteria.andParameterNameLike(parameterName);
		}

		if (StringUtils.isNotBlank(parameterType)) {
			criteria.andParameterTypeEqualTo(parameterType);
		}
		
		queryBean.setSortProperty(IProductModelServiceParameterDAO.SortIndex);

	}

	public long getServiceId() {
		return serviceId;
	}

	public void setServiceId(long serviceId) {
		this.serviceId = serviceId;
	}

	public String getParameterName() {
		return parameterName;
	}

	public void setParameterName(String parameterName) {
		this.parameterName = parameterName;
	}

	public String getParameterType() {
		return parameterType;
	}

	public void setParameterType(String parameterType) {
		this.parameterType = parameterType;
	}

}
